package cn.platform.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.ToString;

import java.time.LocalDateTime;

/**
 * 留言
 */
@Data
@ToString
public class Comment {
    private Integer id;
    private Integer activityId; // 外键：学生作业/活动表ID
    private String content;
    private String senderType; // 家长、老师、学生
    private Integer senderID; // 记录 学生表ID、老师表ID或家长表ID
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime sendTime;

    public void setSenderType(String senderType) {
        this.senderType = switch (senderType){
            case "teacher" -> "老师";
            case "student" -> "学生";
            case "parent"  -> "家长";
            default -> senderType;
        };
    }

    public String getSenderTypeEn() {
        return switch (this.senderType){
            case "老师" -> "teacher";
            case "学生" -> "student";
            case "家长"  -> "parent";
            default -> this.senderType;
        };
    }
}
